package cn.anc.aonicardv.util.ui;

import cn.anc.aonicardv.MyApplication;
import cn.anc.aonicardv.R;
import cn.anc.httpcontrolutil.CarControl;
import cn.anc.httpcontrolutil.CarControlCommand;

/**
 * Created by baobaoding on 2017/5/17.
 */

public class CarControlGuiHandler {
    public static GuiErrorHandler guiErrorHandler = new GuiErrorHandler();
    public static GuiNotificationHandler guiNotificationHandler = new GuiNotificationHandler();

    private static class GuiErrorHandler implements CarControl.OnCarErrorHandler {
        @Override
        public void OnError(int error_code) {

            switch (error_code) {
                case CarControlCommand.CarControlErrorCode.ERROR_CODE_APP_NOT_CONNECTED:
                    UiTool.showToast(MyApplication.getInstance(), MyApplication.getInstance().getString(R.string.tip_cardv_disconnect));
                    break;
                default:
                    break;
            }
        }
    }

    private static class GuiNotificationHandler implements CarControl.OnNotificationHandler {
        @Override
        public void OnNotication(CarControl.NotificationInfo info) {

            if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_DRIVER_TIME_LONG)) {
                UiTool.showToast(MyApplication.getInstance(), "长时间驾驶");
            } else if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_EVENT_VIDEO_RECORD_COMPLETE)) {
                UiTool.showToast(MyApplication.getInstance(), "紧急录像录制完成");
            } else if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_LOW_BATTERY)) {
                UiTool.showToast(MyApplication.getInstance(), "电池电量低");
            } else if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_MOTION_DETECT)) {
                UiTool.showToast(MyApplication.getInstance(), "移动侦测");
            } else if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_OPEN_LIGHT)) {
                UiTool.showToast(MyApplication.getInstance(), "开大灯");
            } else if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_PARKING_VIDEO_RECORD_COMPLETE)) {
                UiTool.showToast(MyApplication.getInstance(), "停车监控视频录制完成");
            } else if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_POWER_OFF)) {
                UiTool.showToast(MyApplication.getInstance(), "记录仪已关机");
            } else if (info.type.equals(CarControlCommand.CarNotify.CAR_NOTIFY_SHORT_VIDEO_RECORD_COMPLETE)) {
                UiTool.showToast(MyApplication.getInstance(), "短视频录制完成");
            }
        }
    }

}
